package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.service.store.awk.bean.BilobaItemBean;
import o.cgz;
import o.chc;
import o.chy;
import o.epv;
import o.eqx;
import o.evx;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public class BilobaItemCard extends BaseHorizontalItemCard {
    public LinearLayout ʻ;
    public TextView ˋ;
    private TextView ᐝ;

    public BilobaItemCard(Context context) {
        super(context);
    }

    public static void ˊ(TextView textView, String str) {
        if (textView != null) {
            if (TextUtils.isEmpty(str)) {
                textView.setVisibility(8);
                return;
            }
            textView.setVisibility(0);
            textView.setText(str);
        }
    }

    public cgz ˏ(View view) {
        ˏ((ImageView) view.findViewById(j.ʻˊ));
        ॱ((TextView) view.findViewById(j.ʽ));
        ˊ((TextView) view.findViewById(j.ॱ));
        this.ˋ = (TextView) view.findViewById(j.ˎ);
        this.ʻ = (LinearLayout) view.findViewById(j.ॱᶥ);
        this.ᐝ = (TextView) view.findViewById(j.ㆍʼ);
        ʽ(view);
        ʼ();
        return this;
    }

    private void ʼ() {
        int ˎ = epv.ˎ(this.ʼॱ, ʻ(), chc.ˋ());
        int i = ˎ / 2;
        if (ʼॱ() != null) {
            LayoutParams layoutParams = ʼॱ().getLayoutParams();
            if (layoutParams != null) {
                layoutParams.width = ˎ;
                layoutParams.height = i;
                ʼॱ().setLayoutParams(layoutParams);
                if (ˈ() != null) {
                    ˈ().setLayoutParams(layoutParams);
                }
            } else {
                return;
            }
        }
        if (this.ʻ != null) {
            LayoutParams layoutParams2 = this.ʻ.getLayoutParams();
            if (layoutParams2 != null) {
                layoutParams2.width = ˎ;
                this.ʻ.setLayoutParams(layoutParams2);
            }
        }
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean != null) {
            super.ˏ(cardBean);
            if (cardBean instanceof BilobaItemBean) {
                BilobaItemBean bilobaItemBean = (BilobaItemBean) cardBean;
                ˎ(bilobaItemBean.ॱˌ(), ʼॱ());
                ˊ(ˊˋ(), bilobaItemBean.v_());
                ˊ(ˋˊ(), bilobaItemBean.ʻᐝ());
                ˊ(this.ˋ, bilobaItemBean.ʼˊ());
                ˋ(this.ᐝ, bilobaItemBean.ˋʻ());
                long ʼˋ = bilobaItemBean.ʼˋ();
                long ʻˋ = bilobaItemBean.ʻˋ();
                long ʻˊ = bilobaItemBean.ʻˊ();
                String ˊ = ˊ(ʻˊ);
                ˊ = this.ʼॱ.getResources().getString(n.ˋʽ, new Object[]{ˊ});
                ˊˋ().setAlpha(1.0f);
                ˋˊ().setAlpha(1.0f);
                this.ˋ.setAlpha(1.0f);
                if (ʼˋ < ʻˋ) {
                    ˊ = ˊ(ʻˋ);
                    ˊ = this.ʼॱ.getResources().getString(n.ˎͺ, new Object[]{ˊ});
                } else if (ʼˋ > ʻˊ) {
                    ˊ = this.ʼॱ.getResources().getString(n.ˑॱ);
                    ˊˋ().setAlpha(0.3f);
                    ˋˊ().setAlpha(0.3f);
                    this.ˋ.setAlpha(0.3f);
                }
                ˊ(this.ˋ, ˊ);
            }
        }
    }

    private void ˎ(String str, ImageView imageView) {
        eqx.ˏ(imageView, str, "image_default_icon");
    }

    public int ˊ() {
        return h.ˌᐝ;
    }

    public int ˎ() {
        return h.ˌᐝ;
    }

    public void ॱ(final chy o_chy) {
        OnClickListener anonymousClass3 = new evx(this) {
            final /* synthetic */ BilobaItemCard ˋ;

            public void ˋ(View view) {
                o_chy.ˏ(0, this.ˋ);
            }
        };
        ˉ().setOnClickListener(anonymousClass3);
        ʼॱ().setOnClickListener(anonymousClass3);
    }

    public int ʻ() {
        return chc.ʽ();
    }

    private String ˊ(long j) {
        if (j != -1) {
            return DateUtils.formatDateTime(this.ʼॱ, j, 131092);
        }
        return "";
    }
}
